import stylistic from '@stylistic/eslint-plugin'
import vueEslintParser from 'vue-eslint-parser'
import js from '@eslint/js'
import vue from 'eslint-plugin-vue'
import globals from 'globals'
import ts from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'

export default [
  js.configs.recommended,
  {
    languageOptions: {
      parser: vueEslintParser,
      parserOptions: {
        parser: {
          ts: tsParser,
          js: 'espree'
        }
      },
      globals: {
        ...globals.browser,
        ...globals.node,
        ...globals.es2015
      }
    }
  },
  {
    plugins: {
      '@stylistic': stylistic
    },
    rules: {
      'accessor-pairs': 2,
      curly: [2, 'multi-line'],
      eqeqeq: [
        'error',
        'always',
        {
          null: 'ignore'
        }
      ],
      'new-cap': [
        2,
        {
          capIsNew: false
        }
      ],
      'no-array-constructor': 2,
      'no-caller': 2,
      'no-console': 1,
      'no-control-regex': 0,
      'no-eval': 2,
      'no-extend-native': 2,
      'no-extra-bind': 2,
      'no-implied-eval': 2,
      'no-inner-declarations': [2, 'functions'],
      'no-iterator': 2,
      'no-label-var': 2,
      'no-labels': [
        2,
        {
          allowLoop: false,
          allowSwitch: false
        }
      ],
      'no-lone-blocks': 2,
      'no-multi-str': 2,
      'no-object-constructor': 2,
      'no-new-wrappers': 2,
      'no-octal-escape': 2,
      'no-proto': 2,
      'no-return-assign': [2, 'except-parens'],
      'no-self-compare': 2,
      'no-sequences': 2,
      'no-sparse-arrays': 2,
      'no-this-before-super': 2,
      'no-throw-literal': 2,
      'no-undef-init': 2,
      'no-unmodified-loop-condition': 2,
      'no-unneeded-ternary': [
        2,
        {
          defaultAssignment: false
        }
      ],
      'no-unused-vars': [
        1,
        {
          vars: 'all',
          args: 'none'
        }
      ],
      'no-useless-call': 2,
      'no-useless-computed-key': 2,
      'no-useless-constructor': 2,
      'one-var': [
        2,
        {
          initialized: 'never'
        }
      ],
      'valid-typeof': 2,
      yoda: [2, 'never'],
      'prefer-const': 2,
      'no-debugger': 0,
      '@stylistic/no-whitespace-before-property': 2,
      '@stylistic/operator-linebreak': [
        2,
        'after',
        {
          overrides: {
            '?': 'before',
            ':': 'before'
          }
        }
      ],
      '@stylistic/padded-blocks': [2, 'never'],
      '@stylistic/quotes': [
        2,
        'single',
        {
          avoidEscape: true,
          allowTemplateLiterals: true
        }
      ],
      '@stylistic/semi': [2, 'never'],
      '@stylistic/semi-spacing': [
        2,
        {
          before: false,
          after: true
        }
      ],
      '@stylistic/space-before-blocks': [2, 'always'],
      '@stylistic/space-before-function-paren': 'off',
      '@stylistic/space-in-parens': [2, 'never'],
      '@stylistic/space-infix-ops': 2,
      '@stylistic/space-unary-ops': [
        2,
        {
          words: true,
          nonwords: false
        }
      ],
      '@stylistic/spaced-comment': [
        2,
        'always',
        {
          markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
        }
      ],
      '@stylistic/template-curly-spacing': [2, 'never'],
      '@stylistic/wrap-iife': [2, 'any'],
      '@stylistic/yield-star-spacing': [2, 'both'],
      '@stylistic/object-curly-spacing': [2, 'always'],
      '@stylistic/array-bracket-spacing': [2, 'never'],
      '@stylistic/arrow-spacing': [
        2,
        {
          before: true,
          after: true
        }
      ],
      '@stylistic/block-spacing': [2, 'always'],
      '@stylistic/brace-style': [
        2,
        '1tbs',
        {
          allowSingleLine: true
        }
      ],
      '@stylistic/comma-dangle': [2, 'never'],
      '@stylistic/comma-spacing': [
        2,
        {
          before: false,
          after: true
        }
      ],
      '@stylistic/comma-style': [2, 'last'],
      '@stylistic/dot-location': [2, 'property'],
      '@stylistic/eol-last': 2,
      '@stylistic/generator-star-spacing': [
        2,
        {
          before: true,
          after: true
        }
      ],
      '@stylistic/indent': [
        2,
        2,
        {
          SwitchCase: 1
        }
      ],
      '@stylistic/jsx-quotes': [2, 'prefer-single'],
      '@stylistic/key-spacing': [
        2,
        {
          beforeColon: false,
          afterColon: true
        }
      ],
      '@stylistic/keyword-spacing': [
        2,
        {
          before: true,
          after: true
        }
      ],
      '@stylistic/new-parens': 2,
      '@stylistic/no-mixed-spaces-and-tabs': 2,
      '@stylistic/no-multi-spaces': 2,
      '@stylistic/no-extra-parens': [2, 'functions'],
      '@stylistic/no-floating-decimal': 2,
      '@stylistic/no-multiple-empty-lines': [
        2,
        {
          max: 1
        }
      ],
      '@stylistic/no-trailing-spaces': 2,
      '@stylistic/jsx-indent-props': [2, 2]
    }
  },
  {
    files: ['src/**/*.vue', '**/*.ts'],
    plugins: {
      '@typescript-eslint': ts,
      vue
    },
    rules: {
      ...ts.configs.recommended.rules,
      'vue/max-attributes-per-line': [
        2,
        {
          singleline: 4,
          multiline: {
            max: 1
          }
        }
      ],
      'vue/singleline-html-element-content-newline': 'off',
      'vue/multiline-html-element-content-newline': 'off',
      'vue/multi-word-component-names': 'off',
      'vue/no-v-html': 'off',
      'vue/html-self-closing': 'off',
      'vue/html-indent': ['error', 2],
      'vue/html-closing-bracket-newline': 2
    }
  }
]
